package mysql

import (
	"gorm.io/gorm"
	"time"
)

type ReservationCouRes struct {
	gorm.Model
	UserId          int       `gorm:"type:int(10);not null;comment:'用户id'"`
	CourseId        int       `gorm:"type:int(10);not null;comment:'课程id'"`
	CourseName      string    `gorm:"type:varchar(100);not null;comment:'课程名称'"`
	CoursePrice     float64   `gorm:"type:double(10,2);not null;comment:'课程价格'"`
	CourseTime      string    `gorm:"type:varchar(50);not null;comment:'课程时间段'"`
	CourseCoach     string    `gorm:"type:varchar(11);not null;comment:'教练'"`
	CourseData      string    `gorm:"type:varchar(50);not null;comment:'课程日期'"`
	CourseStaData   time.Time `gorm:"type:datetime(3);not null;comment:'课程开始时间'"`
	CoursePeoPleNum int       `gorm:"type:int(10);not null;comment:'课程成团人数'"`
	ReservationNum  int       `gorm:"type:int(10);not null;comment:'预约人数'"`
	Stadium         string    `gorm:"type:varchar(100);not null;comment:'场馆'"`
	Address         string    `gorm:"type:varchar(100);not null;comment:'场地'"`
	Notes           string    `gorm:"type:varchar(255);not null;comment:'备注'"`
	Status          int       `gorm:"type:int(10);not null;comment:'状态： 1:正常 2:已取消 3:已完成'"`
}

func ReservationShow(id int64) (result *ReservationCouRes, err2 error) {
	DB.Debug().Where("id = ?", id).Limit(1).Find(&result)
	return
}

func ReservationCreate(res *ReservationCouRes) error {
	return DB.Debug().Create(&res).Error
}

func List(Status int) (result []*ReservationCouRes, err2 error) {
	DB.Debug().Where("status = ?", Status).Find(&result)
	return
}
func ResUpdate(id int) error {
	return DB.Debug().Model(&ReservationCouRes{}).Where("id = ?", id).Save("status").Error
}
